home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 8 / QRZ Ham Radio Callsign Database - Volume 8.iso / pc / files / t_unix / j109lxa4.tar / ax25.h < prev    next >
C/C++ Source or Header  |  1994-06-04  |  9KB  |  272 lines

  1.  /* Mods by G1EMM */
  2. #ifndef    _AX25_H
  3. #define    _AX25_H
  4.  
  5. #ifndef    _GLOBAL_H
  6. #include "global.h"
  7. #endif
  8.  
  9. #ifndef _IP_H
  10. #include "ip.h"
  11. #endif
  12.  
  13. #ifndef    _MBUF_H
  14. #include "mbuf.h"
  15. #endif
  16.  
  17. #ifndef    _IFACE_H
  18. #include "iface.h"
  19. #endif
  20.  
  21. #ifndef    _SOCKADDR_H
  22. #include "sockaddr.h"
  23. #endif
  24.  
  25. /* AX.25 datagram (address) sub-layer definitions */
  26.  
  27. #define    MAXDIGIS    7    /* Maximum number of digipeaters */
  28. #define    ALEN        6    /* Number of chars in callsign field */
  29. #define    AXALEN        7    /* Total AX.25 address length, including SSID */
  30. #define    AXBUF        10    /* Buffer size for maximum-length ascii call */
  31.  
  32. #ifndef _LAPB_H
  33. #include "lapb.h"
  34. #endif
  35.  
  36. /* Bits within SSID field of AX.25 address */
  37. #define    SSID        0x1e    /* Sub station ID */
  38. #define    REPEATED    0x80    /* Has-been-repeated bit in repeater field */
  39. #define    E        0x01    /* Address extension bit */
  40. #define    C        0x80    /* Command/response designation */
  41.  
  42. /* Our AX.25 address */
  43. extern char Mycall[AXALEN];
  44.  
  45. /* List of AX.25 multicast addresses, e.g., "QST   -0" in shifted ASCII */
  46. extern char Ax25multi[][AXALEN];
  47. #define QSTCALL 0
  48. #define NODESCALL 1
  49. #define MAILCALL 2
  50. #define IDCALL 3
  51. /*currently not used in this code*/
  52. #define OPENCALL 4
  53. #define CQCALL 5
  54. #define BEACONCALL 6
  55. #define RMNCCALL 7
  56. #define ALLCALL 8
  57.  
  58. extern int Digipeat;
  59. extern int Ax25mbox;
  60.  
  61. /* Number of chars in interface field. The involved definition takes possible
  62.  * alignment requirements into account, since ax25_addr is of an odd size.
  63.  */
  64. #define    ILEN    (sizeof(struct sockaddr) - sizeof(short) - AXALEN)
  65.  
  66. /* Socket address, AX.25 style */
  67. struct sockaddr_ax {
  68.     short sax_family;        /* 2 bytes */
  69.     char ax25_addr[AXALEN];
  70.     char iface[ILEN];        /* Interface name */
  71. };
  72.  
  73. /* Internal representation of an AX.25 header */
  74. struct ax25 {
  75.     char dest[AXALEN];        /* Destination address */
  76.     char source[AXALEN];        /* Source address */
  77.     char digis[MAXDIGIS][AXALEN];    /* Digi string */
  78.     int ndigis;            /* Number of digipeaters */
  79.     int nextdigi;            /* Index to next digi in chain */
  80.     int cmdrsp;            /* Command/response */
  81. };
  82.  
  83. /* C-bit stuff */
  84. #define    LAPB_UNKNOWN        0
  85. #define    LAPB_COMMAND        1
  86. #define    LAPB_RESPONSE        2
  87.  
  88. /* AX.25 routing table entry */
  89. struct ax_route {
  90.     struct ax_route *next;        /* Linked list pointer */
  91.     char target[AXALEN];
  92.     struct iface *iface;
  93.     char digis[MAXDIGIS][AXALEN];
  94.     int ndigis;
  95.     char type;
  96. #define    AX_LOCAL    1        /* Set by local ax25 route command */
  97. #define    AX_AUTO        2        /* Set by incoming packet */
  98.     char mode;            /* Connection mode (G1EMM) */
  99. #define    AX_DEFMODE    0        /* Use default interface mode */
  100. #define    AX_VC_MODE    1        /* Try to use Virtual circuit */
  101. #define    AX_DATMODE    2        /* Try to use Datagrams only */
  102. };
  103. #define NULLAXR    ((struct ax_route *)0)
  104.  
  105. extern struct ax_route *Ax_routes;
  106. extern struct ax_route Ax_default;
  107.  
  108. /* AX.25 Level 3 Protocol IDs (PIDs) */
  109. #define PID_X25        0x01    /* CCITT X.25 PLP */
  110. #define    PID_SEGMENT    0x08    /* Segmentation fragment */
  111. #define PID_TEXNET    0xc3    /* TEXNET datagram protocol */
  112. #define    PID_LQ        0xc4    /* Link quality protocol */
  113. #define    PID_APPLETALK    0xca    /* Appletalk */
  114. #define    PID_APPLEARP    0xcb    /* Appletalk ARP */
  115. #define    PID_IP        0xcc    /* ARPA Internet Protocol */
  116. #define    PID_ARP        0xcd    /* ARPA Address Resolution Protocol */
  117. #define    PID_RARP    0xce    /* ARPA Reverse Address Resolution Protocol */
  118. #define    PID_NETROM    0xcf    /* NET/ROM */
  119. #define    PID_NO_L3    0xf0    /* No level 3 protocol */
  120.  
  121. #define    SEG_FIRST    0x80    /* First segment of a sequence */
  122. #define    SEG_REM        0x7f    /* Mask for # segments remaining */
  123.  
  124. #define    AX_EOL        "\r"    /* AX.25 end-of-line convention */
  125.  
  126. /* Link quality report packet header, internal format */
  127. struct lqhdr {
  128.     int16 version;        /* Version number of protocol */
  129. #define    LINKVERS    1
  130.     int32    ip_addr;    /* Sending station's IP address */
  131. };
  132. #define    LQHDR    6
  133. /* Link quality entry, internal format */
  134. struct lqentry {
  135.     char addr[AXALEN];    /* Address of heard station */
  136.     int32 count;        /* Count of packets heard from that station */
  137. };
  138. #define    LQENTRY    11
  139.  
  140. /* Link quality database record format
  141.  * Currently used only by AX.25 interfaces
  142.  */
  143. struct lq {
  144.     struct lq *next;
  145.     char addr[AXALEN];    /* Hardware address of station heard */
  146.     struct iface *iface;    /* Interface address was heard on */
  147.     int32 time;        /* Time station was last heard */
  148.     int32 currxcnt;    /* Current # of packets heard from this station */
  149.  
  150. #ifdef    notdef        /* Not yet implemented */
  151.     /* # of packets heard from this station as of his last update */
  152.     int32 lastrxcnt;
  153.  
  154.     /* # packets reported as transmitted by station as of his last update */
  155.     int32 lasttxcnt;
  156.  
  157.     int16 hisqual;    /* Fraction (0-1000) of station's packets heard
  158.              * as of last update
  159.              */
  160.     int16 myqual;    /* Fraction (0-1000) of our packets heard by station
  161.              * as of last update
  162.              */
  163. #endif
  164. };
  165. #define    NULLLQ    (struct lq *)0
  166.  
  167. extern struct lq *Lq;    /* Link quality record headers */
  168.  
  169. /* Structure used to keep track of monitored destination addresses */
  170. struct ld {
  171.     struct ld *next;    /* Linked list pointers */
  172.     char addr[AXALEN];/* Hardware address of destination overheard */
  173.     struct iface *iface;    /* Interface address was heard on */
  174.     int32 time;        /* Time station was last mentioned */
  175.     int32 currxcnt;    /* Current # of packets destined to this station */
  176. };
  177. #define    NULLLD    (struct ld *)0
  178.  
  179. extern struct ld *Ld;    /* Destination address record headers */
  180.  
  181. #ifdef __GNUC__
  182. struct ax25_cb;            /* forward declaration */
  183. #endif
  184.  
  185. /* Linkage to network protocols atop ax25 */
  186. struct axlink {
  187.     int pid;
  188.     void (*funct) __ARGS((struct iface *,struct ax25_cb *,char *, char *,
  189.      struct mbuf *,int));
  190. };
  191. extern struct axlink Axlink[];
  192.  
  193. /* Codes for the open_ax25 call */
  194. #define    AX_PASSIVE    0
  195. #define    AX_ACTIVE    1
  196. #define    AX_SERVER    2    /* Passive, clone on opening */
  197.  
  198. /* Max number of fake AX.25 interfaces for RFC-1226 encapsulation */
  199. #define NAX25       16
  200.  
  201. #define    AXHEARD_PASS    0    /* Log both src and dest callsigns */
  202. #define    AXHEARD_NOSRC    1    /* do not log source callsign */
  203. #define    AXHEARD_NODST    2    /* do not log destination callsign */
  204. #define    AXHEARD_NONE    3    /* do not log any callsign */
  205.  
  206. /* an call that should not be jump-started */
  207. struct no_js {
  208.     struct no_js *next;
  209.     char call[AXALEN];
  210. };
  211.  
  212. /* In ax25.c: */
  213. struct ax_route *ax_add __ARGS((char *,int,char digis[][AXALEN],int,struct iface *));
  214. int ax_drop __ARGS((char *,struct iface *));
  215. struct ax_route *ax_lookup __ARGS((char *,struct iface *));
  216. void axip_input __ARGS((struct iface *iface,struct ip *ip,struct mbuf *bp,int rxbroadcast));
  217. void ax_recv __ARGS((struct iface *,struct mbuf *));
  218. int ax_send __ARGS((struct mbuf *bp,struct iface *iface,int32 gateway,int prec,
  219.     int del,int tput,int rel));
  220. int ax_output __ARGS((struct iface *iface,char *dest,char *source,int16 pid,
  221.     struct mbuf *data));
  222. int sendframe __ARGS((struct ax25_cb *axp,int cmdrsp,int ctl,struct mbuf *data));
  223. void axnl3 __ARGS((struct iface *iface,struct ax25_cb *axp,char *src,
  224.     char *dest,struct mbuf *bp,int mcast));
  225.  
  226. /* In ax25cmd.c: */
  227. void st_ax25 __ARGS((struct ax25_cb *axp));
  228. int axheard __ARGS((struct iface *ifp));
  229.  
  230. /* In axhdr.c: */
  231. struct mbuf *htonax25 __ARGS((struct ax25 *hdr,struct mbuf *data));
  232. int ntohax25 __ARGS((struct ax25 *hdr,struct mbuf **bpp));
  233.  
  234. /* In axlink.c: */
  235. void getlqentry __ARGS((struct lqentry *ep,struct mbuf **bpp));
  236. void getlqhdr __ARGS((struct lqhdr *hp,struct mbuf **bpp));
  237. void logsrc __ARGS((struct iface *iface,char *addr));
  238. void logdest __ARGS((struct iface *iface,char *addr));
  239. char *putlqentry __ARGS((char *cp,char *addr,int32 count));
  240. char *putlqhdr __ARGS((char *cp,int16 version,int32 ip_addr));
  241. struct lq *al_lookup __ARGS((struct iface *ifp,char *addr,int sort));
  242.  
  243. /* In ax25user.c: */
  244. int ax25val __ARGS((struct ax25_cb *axp));
  245. int disc_ax25 __ARGS((struct ax25_cb *axp));
  246. int kick_ax25 __ARGS((struct ax25_cb *axp));
  247. struct ax25_cb *open_ax25 __ARGS((struct iface *,char *,char *,
  248.     int,int16,
  249.     void (*) __ARGS((struct ax25_cb *,int)),
  250.     void (*) __ARGS((struct ax25_cb *,int)),
  251.     void (*) __ARGS((struct ax25_cb *,int,int)),
  252.     int user));
  253. struct mbuf *recv_ax25 __ARGS((struct ax25_cb *axp,int16 cnt));
  254. int reset_ax25 __ARGS((struct ax25_cb *axp));
  255. int send_ax25 __ARGS((struct ax25_cb *axp,struct mbuf *bp,int pid));
  256.  
  257. /* In ax25subr.c: */
  258. int addreq __ARGS((char *a,char *b));
  259. struct ax25_cb *cr_ax25 __ARGS((char *local,char *remote,struct iface *iface));
  260. void del_ax25 __ARGS((struct ax25_cb *axp));
  261. struct ax25_cb *find_ax25 __ARGS((char *local,char *remote,struct iface *iface));
  262. char *pax25 __ARGS((char *e,char *addr));
  263. int setcall __ARGS((char *out,char *call));
  264.  
  265. /* In socket.c: */
  266. void beac_input __ARGS((struct iface *iface,char *src,struct mbuf *bp));
  267. void s_arcall __ARGS((struct ax25_cb *axp,int cnt));
  268. void s_ascall __ARGS((struct ax25_cb *axp,int old,int new));
  269. void s_atcall __ARGS((struct ax25_cb *axp,int cnt));
  270.  
  271. #endif    /* _AX25_H */
  272.